import BaseService from './BaseService.js';

class WalletService extends BaseService {
  constructor() {
    super()
    // `$$prefix` 将自动加在 `url` 前面，除非 `url` 是一个绝对 URL
    this.$$prefix = '/v0/wallet';
    this.$$path = {
    }
  }
  /**获取用户钱包信息 */
  getUserWallet(){
    return this.get("")
  }
  queryList(){
    return this.get("list")
  }

  /**查询订单下是否有剩余红包 */
  orderHasEnvelop(orderId) {
    return this.get(`order/has/envelop/${orderId}`, null, false)
  }
  /**查询工厂下是否有剩余红包 */
  factoryHasEnvelop(factoryId) {
    return this.get(`factory/has/envelop/${factoryId}`, null, false)
  }
  /**发红包 */
  spilt(param){
    return this.post(`envelop/spilt`, {data: param})
  }
  /**拆红包 */
  bonus(envelopesId){
    return this.get(`envelop/bonus/${envelopesId}`)
  }
  /**
   * 根据订单ID获取红包信息 
   */
  getEnvelopesByOrderId(orderId) {
    return this.get(`envelop/order/${orderId}`)
  }
  /**
   * 根据用户ID获取红包信息 
   */
  getEnvelopesByUserId(userId) {
    return this.get(`envelop/user/${userId}`)
  }
  /**
   * 提现申请
   */
  cashApply(param) {
    return this.post(`cash/apply`, {data: param});
  }
  /**
   * 提现确认
   */
  cashSuccess(walletId){
    return this.get(`cash/success/${walletId}`);
  }
}

export default WalletService;